/*
 * @Author: Kevin Zhao
 * @Date: 2020-10-22 20:11:10
 * @LastEditTime: 2022-06-22 20:31:21
 * @LastEditors: Kevin Zhao
 * @Description: 
 * @FilePath: \tongren-rc\src\server\RelayRequest.js
 */
import sign from './MD5SignUtils';
import getuuId from './UUIDUtils';

var reqParamMap = {
  appId: '001',
  bizContent: JSON.stringify({}),
  bizId: '',
  charset: 'utf-8',
  hosCode: '001',
  hosName: '同仁医院',
  ip: '127.0.0.1',
  merchantId: '001',
  method: '',
  // 平台id => { weixin: '03', alipay: '04', APP: '01' }
  pltId: '03',
  requestId: getuuId(),
  rsaType: 'md5',
  terminalId: '000000000',
  timeStamp: new Date().getTime(),
  version: '1.00.01'
};

export default function(data){
    let params = Object.assign({},reqParamMap)
    params.bizContent = JSON.stringify(data.bizContent) || reqParamMap.bizContent
    params.method = data.method || reqParamMap.method
    params.bizId = data.bizId || reqParamMap.bizId
    params.hosCode = localStorage.getItem('hosCode') || reqParamMap.hosCode
    params.sign = sign(params);
    return JSON.stringify(params)
}